from rest_framework.exceptions import APIException

from  app.models import UserToken


class UserAuth():
    def authenticate_header(self,request):
        pass

    def authenticate(self,request):
        token = request.query_params.get('token')
        print(token)
        try:
            token = UserToken.objects.get(token=token)
            return token.user,token.token
        except Exception:
            raise APIException('认证不通过')
